<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    /* 
      https://leetcode-cn.com/problems/merge-two-sorted-lists/
      思路：https://leetcode-cn.com/problems/merge-two-sorted-lists/solution/tu-jie-leetcodehe-bing-liang-ge-you-xu-lian-biao-b/

      输入：1->2->4, 1->3->4
      输出：1->1->2->3->4->4
     */
    function mergeTwoLists(l1, l2) {
      if (!l1) return l2;
      else if (!l2) return l1;
      else if (l1.val < l2.val) {
        l1.next = mergeTwoLists(l1.next, l2)
        return l1;
      } else {
        l2.next = mergeTwoLists(l1, l2.next)
        return l2;
      }
    }
  </script>
</body>
</html>